package de.koller.aframe.gl.obj;

import de.koller.oceanFramework.math.RVec3;
import org.lwjgl.opengl.GL11;

public class Quad extends RenderPrimitiv {

	public Quad() {
		super( GL11.GL_QUADS, 4 );
		this.setTextureLayout( 1, 1 );
	}

	public static Quad createXPlane( float x, float y, float z, float w, float h ) {
		Quad q = new Quad();
		q.update( new RVec3( x,   y  , z ),
				  new RVec3( x,   y-h, z ),
				  new RVec3( x+w, y-h, z ),
				  new RVec3( x+w, y  , z ) );
		return q;
	}
	
	public static Quad createZPlane( float x, float y, float z, float w, float d ) {
		Quad q = new Quad();
		q.update( new RVec3( x,   y, z   ),
				  new RVec3( x,   y, z+d ),
				  new RVec3( x+w, y, z+d ),
				  new RVec3( x+w, y, z   ) );
		return q;
	}
	
	public Quad setTextureLayout( float c, float r ) {
		uv[0] = 0; uv[1] = 0;
		uv[2] = 0; uv[3] = r;
		uv[4] = c; uv[5] = r;
		uv[6] = c; uv[7] = 0;
		
		return this;
	}

}
